#!/bin/bash

# postinst script for driver-storage-cpqary3
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <postinst> \`abort-remove'
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
else
    BASEDIR_OPT="-b $BASEDIR"
fi

case "$1" in
    configure)
        if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/kernel/drv/cpqary3.conf ] && rm -f $BASEDIR/kernel/drv/cpqary3.conf
	else
	    chmod 0644 "$BASEDIR/kernel/drv/cpqary3.conf"
	    chown root:sys "$BASEDIR/kernel/drv/cpqary3.conf"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/kernel/drv/amd64/cpqary3 ] && rm -f $BASEDIR/kernel/drv/amd64/cpqary3
	else
	    chmod 0755 "$BASEDIR/kernel/drv/amd64/cpqary3"
	    chown root:sys "$BASEDIR/kernel/drv/amd64/cpqary3"
	fi
	[ "$ZONEINST" = "1" ] || (grep -c "^cpqary3 " $BASEDIR/etc/name_to_major >/dev/null || ( add_drv -n  $BASEDIR_OPT  -c 'scsi' -i '"pci103c,1920" "pci103c,1921" "pci103c,1922" "pci103c,1923" "pci103c,1924" "pci103c,1926" "pci103c,1928" "pci103c,21bd" "pci103c,21be" "pci103c,21bf" "pci103c,21c0" "pci103c,21c1" "pci103c,21c2" "pci103c,21c3" "pci103c,21c5" "pci103c,21c6" "pci103c,21c7" "pci103c,21c8" "pci103c,21ca" "pci103c,21cb" "pci103c,21cc" "pci103c,21cd" "pci103c,21ce" "pci103c,3211" "pci103c,3212" "pci103c,3223" "pci103c,3225" "pci103c,3234" "pci103c,3235" "pci103c,3237" "pci103c,323d" "pci103c,3241" "pci103c,3243" "pci103c,3245" "pci103c,3247" "pci103c,3249" "pci103c,324a" "pci103c,324b" "pci103c,3350" "pci103c,3351" "pci103c,3352" "pci103c,3353" "pci103c,3354" "pci103c,3355" "pci103c,3356" "pcie11,4070" "pcie11,4080" "pcie11,4082" "pcie11,4083" "pcie11,4091" "pcie11,409a" "pcie11,409b" "pcie11,409c" "pcie11,409d" "pcie11,409e"' cpqary3 ) )
	
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument '$1'" >&2
        exit 1
    ;;
esac



# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

